﻿namespace Sgr.Licence.Services
{
    /// <summary>
    /// 激活码生成器接口
    /// 用于生成和验证软件授权激活码
    /// </summary>
    public interface IActivationCodeGenerator
    {
        /// <summary>
        /// 生成激活码
        /// </summary>
        /// <param name="registrationCode">注册码，基于客户硬件信息生成的唯一标识</param>
        /// <param name="numOfLic">授权数量，表示可激活的设备数量</param>
        /// <param name="startTime">授权开始时间</param>
        /// <param name="endTime">授权结束时间</param>
        /// <returns>加密后的激活码</returns>
        /// <exception cref="ArgumentNullException">当注册码为空时抛出</exception>
        /// <exception cref="ArgumentException">当授权数量小于等于0或时间范围无效时抛出</exception>
        string GenerateActivationCode(
            string registrationCode,
            long numOfLic,
            DateTime startTime,
            DateTime endTime);

        /// <summary>
        /// 验证激活码是否有效
        /// </summary>
        /// <param name="registrationCode">注册码，用于验证激活码是否匹配当前硬件</param>
        /// <param name="activationCode">需要验证的激活码</param>
        /// <returns>
        /// 包含三个元素的元组:
        /// - IsValid: 激活码是否有效
        /// - Message: 验证结果的详细消息
        /// - Info: 激活码包含的授权信息，验证失败时为null
        /// </returns>
        (bool IsValid, string Message, ActivationInfo? Info) ValidateActivationCode(
            string registrationCode,
            string activationCode);
    }
}